<?php

class Kd_Html_Grid_Cell_Datetime extends Kd_Html_Grid_Cell_Text {

	private $_format = 'Y-m-d';

	public function __construct(){
		parent::__construct();
		$this->templateName = 'grid/cell/datetime';
	}

	public function getFormat(){
		return $this->_format;
	}
	public function setFormat($value){
		$this->_format = $value;
		return $this;
	}

	public function getCellText(){
		$result = parent::getCellText();
		if(!empty($result)){
			$result = date($this->getFormat(), strtotime($result));
		}
		return $result;
	}

	protected function render(){
		return '<span>'.$this->getCellText().'</span>';
	}
}